package uk.ac.sanger.utils;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.biojava.dasobert.dasregistry.DasSource;
import org.biojava.services.das.servlets.ServletResponseWriter;

/**
 * Servlet implementation class SangerSources
 */
public class SangerSourcesServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
      
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SangerSourcesServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String proserverPath=getInitParameter("proserverPath");
	    String dazzleUrl=getInitParameter("dazzleUrl");
	    String das_confPath=getInitParameter("das_confPath");
		ProserverIniReader reader = new ProserverIniReader();
		List<DasSource> sources=reader.createSources(dazzleUrl);
		ServletResponseWriter writer = new ServletResponseWriter();
		 System.out.println("writing Sanger das response:");
		writer.writeResponse(response, sources, sources.size(),0, 0, false);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
